﻿using D3StatsClient.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using D3StatsClient.ViewModel;
using System.IO;

namespace D3StatsClient.Commands
{
    public class DeleteSession : CommandBase
    {
        public override bool CanExecute(object parameter)
        {
            return true;
        }

        public override void Execute(object parameter)
        {
            var vm = ViewModelManager<SessionPickerWindowViewModel>.ViewModel;
            SessionPickerEntry spe = parameter as SessionPickerEntry;

            //delete the local file
            File.Delete(spe.XmlDataFile);

            //Remove the entry from the collection
            vm.Sessions.Remove(spe);

        }
    }
}
